import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjCreate } from "../common/ObjCreate";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
type int = number;
//class ZodiacBgPanel
    
    export  class ZodiacBgPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            var loc1=0;
            this._selectBetTitle = new Object /* flash.display.Bitmap */();
            this._selectBetTitle.x = 555;
            this._selectBetTitle.y = 61;
            addChild(this._selectBetTitle);
            this._colorBet = new Object /* flash.display.Bitmap */();
            this._colorBet.x = 486;
            this._colorBet.y = 112;
            addChild(this._colorBet);
            this._animalBet = new Object /* flash.display.Bitmap */();
            this._animalBet.x = 486;
            this._animalBet.y = 167;
            addChild(this._animalBet);
            this._selectMoneyTitle = new Object /* flash.display.Bitmap */();
            this._selectMoneyTitle.x = 557;
            this._selectMoneyTitle.y = 307;
            addChild(this._selectMoneyTitle);
            this._infoTitle = new Object /* flash.display.Bitmap */();
            this._infoTitle.x = 470;
            this._infoTitle.y = 450;
            addChild(this._infoTitle);
            while (loc1 < 3) 
            {
                this._gold = new Object /* flash.display.Bitmap */();
                this._gold.x = 608;
                this._gold.y = loc1 * 21 + 451;
                if (loc1 == 2) 
                {
                    this._gold.y = loc1 * 23 + 451;
                }
                this._gold.bitmapData = GlobalClass.getBitmapData(ImagesConst.Yuanbao_small);
                addChild(this._gold);
                ++loc1;
            }
            this._fontResult = new Object /* flash.display.Bitmap */();
            this._fontResult.x = 170;
            this._fontResult.y = 503;
            addChild(this._fontResult);
            this._curResult = new Object /* flash.display.Bitmap */();
            this._curResult.x = 170;
            this._curResult.y = 503;
            addChild(this._curResult);
            this._nextStart = new Object /* flash.display.Bitmap */();
            this._nextStart.x = 213;
            this._nextStart.y = 272;
            addChild(this._nextStart);
            this._openAwards = new Object /* flash.display.Bitmap */();
            this._openAwards.x = 207;
            this._openAwards.y = 272;
            addChild(this._openAwards);
            var loc2=ObjCreate.createTextField("", 30, 80, 60, 20, this);
            loc2.htmlText = HTMLUtil.addLink(Language.getString(200024), GlobalStyle.color5);
            loc2.toolTipData = Language.getString(200023);
            LoaderHelp.addResCallBack(ResFileConst.Zodiac, this.onResLoaded);
            this._buttonSp = new Object /* flash.display.Sprite */();
            this._buttonSp.x = 501;
            this._buttonSp.y = 200;
            addChild(this._buttonSp);
            this.createBetBtn();
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._selectBetTitle.bitmapData = GlobalClass.getBitmapData(ImagesConst.ZodiacSelectBet);
            this._colorBet.bitmapData = GlobalClass.getBitmapData(ImagesConst.ZodiacColor);
            this._animalBet.bitmapData = GlobalClass.getBitmapData(ImagesConst.ZodiacAnimal);
            this._selectMoneyTitle.bitmapData = GlobalClass.getBitmapData(ImagesConst.ZodiacSelectMoney);
            this._infoTitle.bitmapData = GlobalClass.getBitmapData(ImagesConst.ZodiacTitle);
            this._nextStart.bitmapData = GlobalClass.getBitmapData(ImagesConst.ZodiacNext);
            this._openAwards.bitmapData = GlobalClass.getBitmapData(ImagesConst.ZodiacTimeCount);
            this._fontResult.bitmapData = GlobalClass.getBitmapData(ImagesConst.ZodiacFrontResult);
            this._curResult.bitmapData = GlobalClass.getBitmapData(ImagesConst.ZodiacCurrentResult);
            return;
        }

        /* internal  */createBetBtn(): void
        {
            var loc1=1;
            while (loc1 < 13) 
            {
                this._animalBtn = ObjCreate.createGLoadedButton(ResFileConst["ZodiacAnimalBetBtn" + loc1], (loc1 - 1) % 6 * 32 + (loc1 - 1) % 6 * 15, int(loc1 / 7) * 32 + int(loc1 / 7) * 15, 32, 32, this._buttonSp);
                this._animalBtn.name = String(loc1);
                if (!this._animalBtn.hasEventListener(flash.events.MouseEvent.CLICK)) 
                {
                    this._animalBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBetAnimal);
                }
                ++loc1;
            }
            return;
        }

        /* internal  */onBetAnimal(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=0;
            while (loc1 < this._buttonSp.numChildren) 
            {
                if (this._buttonSp.getChildAt(loc1).name == arg1.currentTarget.name) 
                {
                    (arg1.currentTarget as GLoadedButton).filters = [FilterConst.gradientGlowFilter];
                    Dispatcher.dispatchEvent(new DataEvent(EventName.OnSelectAnimal, (arg1.currentTarget as GLoadedButton).name));
                }
                else 
                {
                    this._buttonSp.getChildAt(loc1).filters = null;
                }
                ++loc1;
            }
            return;
        }

        public updateUI(): void
        {
            LoaderHelp.addResCallBack(ResFileConst.Zodiac, this.onResLoaded);
            return;
        }

        public set imgVisible(arg1: int)
        {
            if (arg1 != 0) 
            {
                this._nextStart.visible = loc1 = true;
                this._curResult.visible = loc1;
                this._openAwards.visible = loc1 = false;
                this._fontResult.visible = loc1;
            }
            else 
            {
                var loc1;
                this._openAwards.visible = loc1 = true;
                this._fontResult.visible = loc1;
                this._nextStart.visible = loc1 = false;
                this._curResult.visible = loc1;
            }
            return;
        }

        /* internal */ /* var */_selectBetTitle: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_colorBet: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_animalBet: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_selectMoneyTitle: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_gold: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_infoTitle: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_animalBtn: GLoadedButton;

        public /* var */_buttonSp: Object /* flash.display.Sprite */;

        public /* var */_fontResult: Object /* flash.display.Bitmap */;

        public /* var */_curResult: Object /* flash.display.Bitmap */;

        public /* var */_nextStart: Object /* flash.display.Bitmap */;

        public /* var */_openAwards: Object /* flash.display.Bitmap */;
    }
